package com.hnevc.acountms.activity;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.hnevc.acountms.R;
import com.hnevc.acountms.model.Tb_flag;

public class FlagAddActivity extends AppCompatActivity {
    EditText mEtFlag;
    Button mBtnSave;
    Button mBtnCancel;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_flag_add);
        initView();
        initEvent();
    }

    private void initEvent() {
        mBtnSave.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Tb_flag flag = new Tb_flag();
                flag.setFlag(mEtFlag.getText().toString());
                flag.save();
                Toast.makeText(FlagAddActivity.this, "保存成功", Toast.LENGTH_SHORT).show();
            }
        });
        mBtnCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mEtFlag.setText("");
            }
        });
    }

    private void initView() {
        mEtFlag = (EditText) findViewById(R.id.id_et_flag);
        mBtnSave = (Button) findViewById(R.id.id_btn_save);
        mBtnCancel = (Button) findViewById(R.id.id_btn_cancel);
    }

    public static void actionStart(Context context) {
        Intent intent = new Intent(context,FlagAddActivity.class);
        context.startActivity(intent);
    }
}
